****** Table_11_6:  Instrumental Variable Analysis
use data/Demo_book_country_3.dta, clear

************ democracy variables

* polyarchy, 100-point scale
gen v2x_polyarchy_100 = (v2x_polyarchy / .924) * 100

* polyarchy, missing obs imputed
impute v2x_polyarchy lexical_index inc_chall_combined , gen(v2x_polyarchy_imp)
* 100-point scale
replace v2x_polyarchy_imp = v2x_polyarchy_imp * 100
gen v2x_polyarchy_imp_100 = (v2x_polyarchy_imp / 92.4) * 100
replace v2x_polyarchy_imp_100 = . if sovereign_Cojocaru ==.


*1) pop density: bivariate model
qui ivregress 2sls v2x_polyarchy_imp_100 decade* (eur_pct_est_smooth = lpd1500) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) replace
qui drop sample

*2) pop density: geographic covariates
qui ivregress 2sls v2x_polyarchy_imp_100 predallports53_100km lp_lat_abst decade* (eur_pct_est_smooth = lpd1500) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) append
qui drop sample

*3) pop density: full specification
qui ivregress 2sls v2x_polyarchy_imp_100 predallports53_100km lp_lat_abst murdock_dem chrstprotpct Muslim durbritain_new decade* (eur_pct_est_smooth = lpd1500) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) append
qui drop sample

*4) temperature
qui ivregress 2sls v2x_polyarchy_imp_100 predallports53_100km lp_lat_abst decade* (eur_pct_est_smooth = avg_temp) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) append
qui drop sample

*5) distance from London, squared
qui ivregress 2sls v2x_polyarchy_imp_100 predallports53_100km lp_lat_abst decade* (eur_pct_est_smooth = c.london_dist_ln##c.london_dist_ln) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) append
qui drop sample

*6) settler mortality
qui ivregress 2sls v2x_polyarchy_imp_100 predallports53_100km lp_lat_abst decade* (eur_pct_est_smooth = el_settlermort) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) append
qui drop sample

*7) Index of the stability of malaria transmission based biological characteristics of mosquitos such as the proportion of blood meals taken from human hosts, daily survival of the mosquito, and duration of the transmission season and of extrinsic incubation. From Easterly & Levine (2018), who draw on Kiszewski et al. (2004). 
qui ivregress 2sls v2x_polyarchy_imp_100 predallports53_100km lp_lat_abst decade* (eur_pct_est_smooth = el_ME) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) append
qui drop sample

*8) agricultural transition, 1000s of years since
qui ivregress 2sls v2x_polyarchy_imp_100 predallports53_100km lp_lat_abst decade* (eur_pct_est_smooth = agritran) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) append
qui drop sample

*9) state history
qui ivregress 2sls v2x_polyarchy_imp_100 predallports53_100km lp_lat_abst decade* (eur_pct_est_smooth = statehiste1500_01n) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) append
qui drop sample

*10) all
qui ivregress 2sls v2x_polyarchy_imp_100 decade* (eur_pct_est_smooth = lpd1500 statehiste1500_01n agritran el_ME el_settlermort c.london_dist_ln##c.london_dist_ln avg_temp) if europe_harbors_def == 0, vce(cluster country_id)
qui gen sample = e(sample)
qui tab country_id if sample == 1, nofreq
qui local countries=r(r)
qui tab year if sample == 1, nofreq
qui local years=r(r)
qui outreg2 using output/Table_11_6.doc, nor noni nonot nocon stats(coef tstat) addstat("Countries", `countries', "Years", `years', "R-squared", e(r2)) addn("*** p<0.01, ** p<0.05, * p<0.1") se bdec(3) keep(eur_pct_est_smooth) replace
qui drop sample
